/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tableview;

import data.Vacancies;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Hùng
 */
public class VacancyTableView extends AbstractTableModel {

    List<Vacancies> lVacanies;

    public VacancyTableView() {
    }

    public VacancyTableView(List<Vacancies> lVacanies) {
        this.lVacanies = lVacanies;
    }

    public List<Vacancies> getlVacanies() {
        return lVacanies;
    }

    public void setlVacanies(List<Vacancies> lVacanies) {
        this.lVacanies = lVacanies;
    }

    @Override
    public int getRowCount() {
        if (lVacanies != null) {
            return this.lVacanies.size();
        }
        return 0;
    }

    @Override
    public int getColumnCount() {
        return 8;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Object value = null;
        Vacancies vacancies = this.lVacanies.get(rowIndex);
        switch (columnIndex) {
            case 0:
                value = vacancies.getVacancyid();
                break;
            case 1:
                value = vacancies.getDepartments().getDeptname();
                break;
            case 2:
                if (vacancies.getSections() != null) {
                    value = vacancies.getSections().getSectname();
                }
                break;
            case 3:
                value = vacancies.getDesignation().getDesignation();
                break;
            case 4:
                value = vacancies.getNoofvacancies();
                break;
            case 5:
                value = vacancies.getVacancydate();
                break;
            case 6:
                value = vacancies.getPriority();
                break;
            case 7:
                value = vacancies.getStatus();
                break;
        }
        return value;
    }

    @Override
    public String getColumnName(int column) {
        String value = "";
        switch (column) {
            case 0: value = "VacanyId";
                break;
            case 1:value = "DeptName";
                break;
            case 2:value = "Section";
                break;
            case 3:value = "Designation";
                break;
            case 4:value = "Number";
                break;
            case 5:value = "Date";
                break;
            case 6:value = "Priority";
                break;
            case 7:value = "Status";
                break;
        }
        return value;
    }
}
